
#include "Canvas.h"

namespace animationagent {


void Canvas::init()
{
}

Canvas::Canvas() :
    Widget(),
    image(NULL)
{
    init();
}

Canvas::Canvas(SDL_Surface *pic) :
    Widget(),
    image(pic)
{
    init();
    set_allocation(0, 0, image->w, image->h);
}

Canvas::~Canvas()
{
}

void Canvas::set_image(SDL_Surface *pic)
{
    image = pic;


    SDL_Rect rect = get_allocation();
    if (image != NULL) {
        rect.w = image->w;
        rect.h = image->h;
    }
    set_allocation(rect);
}

SDL_Surface * Canvas::get_image()
{
    return image;
}

void Canvas::draw(SDL_Surface *screen)
{
    if (!visible) {
        return;
    }
    Widget::draw(screen);
}

void Canvas::update()
{
    p_surface = image;
    Widget::update();
}


}
